package com.ss.android.newmedia.a;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public abstract class AbstractFooter {
    public View mFooterContent;
    public TextView mTextView;
    public View mLoadingView;
    public Button mRetryView;
    public TextView mMoreView;
    public View mAltView;
    public final View mFooterTopDivider;
    public final View mFooterBottomDivider;
    public int mCurrentState;
    private View mSofaView;
    private boolean initialized;
    public static final int STATE_IDLE = 0;
    public static final int STATE_EROR = 2;
    public static final int STATE_MORE_CONTENT = 3;
    public static final int STATE_NO_MORE_CONTENT = 5;
    public static final int STATE_LOADING = 6;

    public AbstractFooter(View content) {
        this.mCurrentState = 0;
        this.mFooterContent = content;
        this.mLoadingView = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_loading);
        this.mTextView = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_text);
        this.mRetryView = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_retry);
        this.mRetryView.setOnClickListener(new z(this));
        this.mAltView = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_alt_view);
        this.mMoreView = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_more);
        this.mMoreView.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View arg2) {
                AbstractFooter.this.onUserClick();
            }
        });
        this.mSofaView = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_sofa);
        this.mFooterTopDivider = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_footer_top_divider);
        this.mFooterBottomDivider = this.mFooterContent.findViewById(com.ss.android.article.browser.R.id.ss_footer_bottom_divider);
        this.initialized = true;
    }

    public abstract void onUserClick();

    public final void switchToError(int resId) {
        this.mCurrentState = 2;
        this.mTextView.setText(resId);
        this.mFooterContent.setVisibility(View.VISIBLE);
        this.mMoreView.setVisibility(View.GONE);
        this.mAltView.setVisibility(View.VISIBLE);
        this.mLoadingView.setVisibility(View.GONE);
        this.mRetryView.setVisibility(View.VISIBLE);
        this.hideSofaView();
    }

    public void switchToLoading() {
        if (this.mCurrentState != 6) {
            this.mCurrentState = 6;
            this.mFooterContent.setVisibility(View.VISIBLE);
            this.mMoreView.setVisibility(View.GONE);
            this.mAltView.setVisibility(View.VISIBLE);
            this.mLoadingView.setVisibility(View.VISIBLE);
            this.mRetryView.setVisibility(View.GONE);
            this.mTextView.setText(com.ss.android.article.browser.R.string.ss_loading);
            this.hideSofaView();
        }
    }

    public final void setViewMoreText(int resId) {
        this.mMoreView.setText(resId);
    }

    public final void switchToNoMoreContent(int resId) {
        this.mCurrentState = 5;
        this.mFooterContent.setVisibility(View.VISIBLE);
        this.mMoreView.setVisibility(View.GONE);
        this.mAltView.setVisibility(View.VISIBLE);
        this.mLoadingView.setVisibility(View.GONE);
        this.mRetryView.setVisibility(View.GONE);
        this.mTextView.setText(this.mFooterContent.getContext().getString(resId));
        this.hideSofaView();
    }

    public final void hideFooterContent() {
        if (this.mCurrentState != 1) {
            this.mCurrentState = 1;
            this.mFooterContent.setVisibility(View.GONE);
        }
    }

    public final void setLoadingText(int stringResId) {
        if (this.initialized) {
            this.mTextView.setText(stringResId);
        }
    }

    public final void hideSofaView() {
        if (this.mSofaView != null) {
            this.mSofaView.setVisibility(View.GONE);
        }

        if (this.mFooterTopDivider != null) {
            this.mFooterTopDivider.setVisibility(View.VISIBLE);
        }

        if (this.mFooterBottomDivider != null) {
            this.mFooterBottomDivider.setVisibility(View.VISIBLE);
        }
    }

    public final void switchToMoreContent() {
        if (this.mCurrentState != 3) {
            this.mCurrentState = 3;
            this.mFooterContent.setVisibility(View.VISIBLE);
            this.mMoreView.setVisibility(View.VISIBLE);
            this.mAltView.setVisibility(View.GONE);
            this.hideSofaView();
        }
    }

    public final void hide() {
        this.mMoreView.setVisibility(View.GONE);
        this.mAltView.setVisibility(View.GONE);
        this.mLoadingView.setVisibility(View.GONE);
        this.mRetryView.setVisibility(View.GONE);
    }
}

